const core = (function () {
    let heartBeat = (pluginName, hostCode, servername) => {
        let ret = null;
        window.ajax("https://meiri56.com/rest-api/token/plugin/heartbeat", JSON.stringify({
                pluginName: pluginName,
                hostCode: hostCode,
                serverName: servername
            }), {
                method: "post",
                async: false
            }, async function (res) {
                ret = res;
            }
        )
        return ret;
    };
    let getAccount = (pluginName, hostCode, servername) => {
        let ret = null;
        window.ajax("https://meiri56.com/rest-api/token/plugin/getAccount", JSON.stringify({
                pluginName: pluginName,
                hostCode: hostCode,
                serverName: servername
            }), {
                method: "post",
                async: false
            }, async function (res) {
                ret = res;
            }
        )
        if (!!ret && !!ret.data) {
            return ret.data
        }
        return null;
    };
    let updateAccount = (accountInfo) => {
        let ret = null;
        window.ajax("https://meiri56.com/rest-api/token/plugin/updateAccount", JSON.stringify(accountInfo), {
                method: "post",
                async: false
            }, async function (res) {
                ret = res;
            }
        )
        if (!!ret && !!ret.data) {
            return ret.data
        }
        return null;
    };
    let sendMsg = (hostCode, msg) => {
        let ret = null;
        window.ajax("https://meiri56.com/rest-api/token/sendMsg", JSON.stringify({
                hostCode: hostCode,
                msg: msg
            }), {
                method: "post",
                async: false
            }, async function (res) {
                ret = res;
            }
        )
        if (!!ret && !!ret.data) {
            return ret.data
        }
        return null;
    };

    return {
        heartBeat: heartBeat,
        getAccount: getAccount,
        updateAccount: updateAccount,
        sendMsg: sendMsg
    }
})()